<?php

namespace App\Models\Participant;

class ParticipantRepository implements \App\Contracts\Repositories\ParticipantRepository
{
    public function getParticipantById($id)
    {
        return Participant::find($id);
    }

    public function getParticipantIdByOpenID($openID, $source)
    {
        return Participant::where([['openid', $openID], ['source', $source]])->first();
    }

    public function createParticipant($openID, $source)
    {
        return Participant::create(
            [
                'openid' => $openID,
                'source' => $source
            ]
        );
    }

    public function findUserByEmptyName()
    {
        return Participant::where('nickname', '')->get();
    }

    public function getParticipantByOpenID($openID)
    {
        return Participant::where('openid', $openID)->first();
    }

    public function getParticipantByUniqueID($uniqueID)
    {
        return Participant::where('uniqueid', $uniqueID)->first();
    }

}
